package com.zhuimeng.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zhuimeng.mapper.ArticleMapper;
import com.zhuimeng.pojo.Article;
import com.zhuimeng.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleMapper mapper;

    @Override
    public Map<String, Object> findAll(Integer pageNum, Integer pageSize) {
        Map<String, Object> data = new HashMap<>();
        Page page = PageHelper.startPage(pageNum, pageSize, true);
        List<Article> list = mapper.findAll();
        data.put("totalPages", page.getPages());
        data.put("pageNum", pageNum);
        data.put("list", list);
        return data;
    }
}
